namespace SubhadraSolutions.Sharp.Logging.Adapters.Log4Net.Context
{
    using log4net;
    using SubhadraSolutions.Sharp.Logging.Context;
    using SubhadraSolutions.Sharp.Logging.Contracts;

    public class Log4NetGlobalContextStrategy : IGlobalContextStrategy
    {
        #region Fields

        private readonly IGlobalContextStrategy _innerStrategy;

        #endregion Fields

        #region Constructors

        public Log4NetGlobalContextStrategy()
        {
            _innerStrategy = LoggingContext.Instance.Strategy;
        }

        #endregion Constructors

        #region Indexers

        public object this[string name]
        {
            get { return _innerStrategy[name]; }
            set
            {
                _innerStrategy[name] = value;
                GlobalContext.Properties[name] = value;
            }
        }

        #endregion Indexers

        #region Methods

        public void Remove(string name)
        {
            _innerStrategy.Remove(name);
            GlobalContext.Properties.Remove(name);
        }

        #endregion Methods
    }
}